<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>

    <link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}css/reset.css" media="screen"/>
    <link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}css/text.css" media="screen"/>
    <link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}css/960.css" media="screen"/>
    <link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}css/layout.css" media="screen"/>
    <!--[if IE 6]><link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}css/ie6.css" media="screen" /><![endif]-->
    <!--[if IE 7]><link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}css/ie.css" media="screen" /><![endif]-->
    <script type="text/javascript" src="{{ MEDIA_URL }}js/jquery.min.js"></script>
    <script type="text/javascript" src="{{ MEDIA_URL }}js/jquery.blockUI.js"></script>
    <script type="text/javascript">
  /*<![CDATA[*/
  $(function() {
      var form = $("#r_form");
      form.submit(function(e) {

          var jqxhr = $.ajax({
                      type: "POST",
                      url: form.attr('action'),
                      data: form.serializeArray(),
                      async: false,
                      beforeSend: function( xhr ) {
                          $.blockUI({ message: '<h1> Запрос обрабатывается...</h1>' });
                      },
                      success: function(data){$.unblockUI();}
                  });
          return false; // установить true если хотим чтобы страница обновлялась и был двойной POST запрос.. =)
      });

  });
  /*]]>*/
  </script>
</head>
<body>

<div class="grid_12">
    <div class="grid_8">
    <p>
        {% for item in user.get_profile.unit_access.all %}

        {% if item != unit %}
            <a href="{% url repairs_add repair.id item.id %}"
                    onclick="$('#r_form').submit();window.location='{% url repairs_add repair.id item.id %}';return false;">{{ item.abb }}</a>
        {% else %}
            {{ item.abb }}
        {% endif %}

        {% endfor %}
    </p>
    </div>
    <div class="clear"></div>
    

    <div class="grid_12">

    <form id="r_form" method="POST" action="{% url repairs_add repair.id unit.id %}" ><div id="ajaxwrapper">{% csrf_token %}
    <table class="tabl_rep">
    <td><strong class="big_text">{{ unit.abb }}</strong></td>{% for date in repair.get_dates %}<td><strong>{{ date|date:"j.n.Y D." }}</strong></td>{% endfor %}
    {% for wor in qs %}
        <tr class={% cycle 'color1' 'color2' %}><td><strong>{{ wor.worker }}</strong></td>
            {% for comp in wor.d_comp %}

                <td>
                    <select name="worker_comp">
                        <option value="{{ wor.worker.id }},{{ forloop.counter0 }},0">Не участвует</option>
                            {% for item in choices %}
                                 <option
                                         {% if item == comp %}
                                                selected
                                           {% endif %}
                                 value="{{ wor.worker.id }},{{ forloop.parentloop.counter0 }},{{ item.id }}">{{ item }}</option>
                                {% endfor %}
                            </select>
                </td>
            {% endfor %}
        </tr>
    {% endfor %}
    </table>
    </div>
    <p id="sendwrapper"><input type="submit" value="Внести данные" id="sendbutton" /></p>
    </form>
    </div>
<div class="clear"></div>

</div>
</body>
</html>
